package Day35.listTest.Test;

import java.util.Iterator;
import java.util.TreeSet;

/**
 * @author hyhWTX
 * @version 1.0
 * @ClassName Test04
 * @date 2022年08月05日 11:27
 * @Description: 集合类测试题练习4
 * 1.4	实例化一个TreeSet集合，放入十个字符串，使用迭代器遍历该集合输出到控制台；
 */
public class Test04 {
    public static void main(String[] args) {
        TreeSet<String> treeSet = new TreeSet<>();
        treeSet.add("wwwww1");
        treeSet.add("wwwww2");
        treeSet.add("wwwww3");
        treeSet.add("wwwww4");
        treeSet.add("wwwww5");
        treeSet.add("wwwww6");
        treeSet.add("wwwww7");
        treeSet.add("wwwww8");
        treeSet.add("wwwww9");
        treeSet.add("wwwww10");

        Iterator<String> iterator = treeSet.iterator();
        while (iterator.hasNext()){
            String next = iterator.next();
            System.out.println(next);
        }
        TreeSet<Book1> books = new TreeSet<Book1>();
        Book1 book1 = new Book1(1,"完美世界",10);
        Book1 book2 = new Book1(2,"斗罗大陆1",10);
        Book1 book3 = new Book1(3,"斗罗大陆2",10);
        Book1 book4 = new Book1(4,"斗罗大陆3",10);
        Book1 book5 = new Book1(5,"斗罗大陆4",10);
        Book1 book6 = new Book1(6,"斗罗大陆5",10);
        books.add(book1);
        books.add(book2);
        books.add(book3);
        books.add(book4);
        books.add(book5);
        books.add(book6);

        for (Book1 book : books) {
            System.out.println(book);
        }
    }
}
